<?php
$profil=sqlServicesFunctions::getProfil(Session::getIDPerson())->next();
$anreden = sqlServicesFunctions::getAnrede();
$alltitel = sqlServicesFunctions::getTitel();
?>
<html lang="de">
<head>
<meta charset="utf-8">
<link rel="stylesheet"
	href="jquery-ui-1.10.4.custom/development-bundle/themes/custom-theme/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<!--<script src="../classes/checks.js" type="text/javascript"></script>-->
<script type="text/javascript">
  $(function() {
    $( "input[type=button], button" )
      .button()
      .click(function( event ) {
        event.preventDefault();
      });
 });
</script>
<script type="text/javascript">

	function updateProfil(idperson){
	$.getScript("classes/AJAXHelper.js", function() {
		doAJAX("updateProfil", document.getElementById('Anrede').value+","
				+document.getElementById('Titel').value+","
				+document.getElementById('Vorname').value+","
				+document.getElementById('Name').value+","
				+document.getElementById('Strasse').value+","
				+document.getElementById('Hausnummer').value+","
				+document.getElementById('Ort').value+","
				+document.getElementById('PLZ').value+","
				+document.getElementById('Telefonnummer').value+","
				+document.getElementById('Faxnummer').value+","
				+document.getElementById('EMailAdresse').value+","
				+idperson, function(){if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
											alert(xmlhttp.responseText);
											}
										});
	});
	}

	function changepasswort(idperson){
		$.getScript("classes/AJAXHelper.js", function() {
			doAJAX("changepasswort", document.getElementById('altesPasswort').value+","
					+document.getElementById('neuesPasswort').value+","
					+document.getElementById('neuesPassworterneut').value+","
					+idperson, function(){if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
												alert(xmlhttp.responseText);
												}
											});
		});
	}
</script>
</head>
<body>
<span id="hinweismeldung"></span>
<div>
<table class="table">
	<tr>
		<td>Anrede</td>
		<td><select id="Anrede" style="width: 100%">
		<?php
		while ($anrede = $anreden->next()) {
			$selecta = null;
			if ($anrede['ABezeichnung']==$profil['Anrede']){ $selecta='selected';}
			echo '<option value="' . $anrede['ABezeichnung'] . '" '. $selecta.'>' . $anrede['ABezeichnung'] . '</option>';
		}
		?>
		</select></td>
	</tr>
	<tr>
		<td>Titel</td>
		<td><select id="Titel" style="width: 100%">
		<?php
		while ($titel = $alltitel->next()) {
		$selectt = null;
			if ($titel['TBezeichnung']==$profil['Titel']){ $selectt='selected';}
			echo '<option value="' . $titel['TBezeichnung'] . '" '.$selectt.'>' . $titel['TBezeichnung'] . '</option>';
		}
		?>
		</select></td>
	</tr>
	<tr>
		<td>Name</td>
		<td><input id="Name" style="width: 100%"
			value="<?php echo $profil['Name']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>Vorname</td>
		<td><input id="Vorname" style="width: 100%"
			value="<?php echo $profil['Vorname']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>Stra&szlig;e</td>
		<td><input id="Strasse" style="width: 100%"
			value="<?php echo $profil['Strasse']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>Hausnummer</td>
		<td><input id="Hausnummer" style="width: 100%"
			value="<?php echo $profil['Hausnummer']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>PLZ</td>
		<td><input id="PLZ" style="width: 100%"
			value="<?php echo $profil['PLZ']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>Ort</td>
		<td><input id="Ort" style="width: 100%"
			value="<?php echo $profil['Ort']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>E-Mail</td>
		<td><input id="EMailAdresse" style="width: 100%"
			value="<?php echo $profil['EMailAdresse']?>" onclick="this.select();"></td>
	</tr>
	<tr>
		<td>Telefon</td>
		<td><input id="Telefonnummer" style="width: 100%"
			value="<?php echo $profil['Telefonnummer']?>"
			onclick="this.select();"></td>
	</tr>
	<tr>
		<td>Faxnummer</td>
		<td><input id="Faxnummer" style="width: 100%"
			value="<?php echo $profil['Faxnummer']?>" onclick="this.select();"></td>
	</tr>
</table>
<input type=button value="zur&uuml;ck"
	onclick="self.location.href='index.php'" /> <input type="button"
	name="button" value="Speichern" onclick="updateProfil(<?php echo Session::getIDPerson()?>)" /></div>
<br><br>
<h2>Passwort &auml;ndern</h2>
<div>
<table class="table">
	<tr>
		<td>altes Passwort</td>
		<td><input id="altesPasswort" type="password" style="width: 100%"
			onclick="this.select();"></td>
	</tr>
	<tr>
		<td>neues Passwort</td>
		<td><input id="neuesPasswort" type="password" style="width: 100%"
			 onclick="this.select();"></td>
	</tr>
	<tr>
		<td>neues Passwort erneut</td>
		<td><input id="neuesPassworterneut" type="password" style="width: 100%"
			onclick="this.select();"></td>
	</tr>
</table>

<input type=button value="zur&uuml;ck"
	onclick="self.location.href='index.php'" /> <input type="button"
	name="button" value="Passwort &auml;ndern" onclick="changepasswort(<?php echo Session::getIDPerson()?>)" /></div>

</body>
</html>
